require([
    'jquery',
    'bootstrap',
    'dataTables',
    'dataTablesBts',
    'css!../../js/bootstrap/css/bootstrap.css',     //css路径写法
    'css!../../js/dataTables/css/dataTables.bootstrap.css'
], function ($, bootstrap, dataTables, dataTablesBts) {

    $(document).ready(function () {

        var table = $('#myTable').DataTable({
            paging: true,
            processing: false,
            searching: false,
            lengthMenu: [5, 10, 20, 50, 100],
            scrollY: 255,//垂直滚动条
            scrollX: true,//水平滚动条
            //使用对象数组，一定要配置columns，告诉 DataTables 每列对应的属性
            //data 这里是固定不变的，name，position，salary，office 为你数据里对应的属性
            columns: [
                {
                    sTitle: '序号',
                    data: null,
                    searchable: false,//第一列不参与搜索
                    className: 'text-center whiteSpace',
                    render: function (data, type, row, meta) {
                        return meta.row + 1 +
                            meta.settings._iDisplayStart;
                    }
                },
                {data: 'id'},
                {data: 'userId'},
                {
                    data: function (data, rowData, rowIndex) {//date类型日期转json传入前端显示
                        var JsonDateValue = new Date(data.loginTime.time);
                        var text = JsonDateValue.toLocaleString();
                        return text;
                    }

                },
                {data: 'loginUserIp', bSortable: false},
                {data: 'loginDesc', bSortable: false}
            ],
            serviceSize: true,
            ajax: {
                type: 'POST',
                url: '../loginLog/ajax/list.json',
                dataSrc: 'data'
            },
            language: {//中文设置
                url: "../../txt/zh_CN.txt"
            },
            fnDrawCallback: function () {
                var api = this.api();
                api.column(0).nodes().each(function (cell, i) {
                    cell.innerHTML = i + 1;
                });
            },
        });


    });

});

